using System;

namespace FunctionalProgramming.PatternMatching.TransformingRules
{
   internal class PredicateMatchingFuncOutput<TIn, TOut> : ITransformingRule<TIn, TOut>
   {
      private readonly Predicate<TIn> predicate;
      private readonly Func<TIn, TOut> outputFunc;

      public PredicateMatchingFuncOutput(Predicate<TIn> predicate, Func<TIn, TOut> outputFunc)
      {
         this.predicate = predicate;
         this.outputFunc = outputFunc;
      }

      public bool DoesInputMatch(TIn input)
      {
         bool result = predicate(input);
         return result;
      }

      public TOut TransformInput(TIn input)
      {
         TOut result = outputFunc(input);
         return result;
      }
   }
}